<!-- 0 项目审批  1 项目督办 2 项目回款 3 任务指派 4 通知消息 5 延期申请 -->

<template>
<view class="page">	  
	<view v-if="isLogin" class="body">
		<c-loading v-if="loadingState.default" :loadingState="loadingState"></c-loading>
		
		<template v-else>
			<template v-if="sp.project">
				<view class="msg-title">{{detail.title}}</view>
				<view class="content">{{detail.content}}</view> 
				<view v-if="detail.comment" class="content">
					<view class="f-wb m-b1">审批意见</view>
					<view>{{detail.comment}}</view>
				</view>
								 
				<view v-if="detail.delay_time" class="content">
					<view class="f-wb m-b1">申请延期时间</view>
					<view>{{detail.delay_time}}</view>
				</view>
				<view v-if="type!=0" class="msg-tips">
					<view class="m-b2">系统通知</view>
					<view>{{detail.create_time}}</view>
				</view>
				
				<view class="sp-step-area m-b2 m-t2">
					<view class="hd">项目</view>
					<navigator :url="'/package_project/project-detail/project-detail?scene=1&id='+sp.project.id" open-type="redirect" hover-class="none" class="porject-bar">
						<view class="title split">{{sp.project.project_name}}</view>
						<text>查看</text>
					</navigator>
				</view>	
				
				<!-- 审批 -->
				<template v-if="type==0">
					<view class="sp-step-area m-b2">
						<view class="hd">审批过程</view>
						<view class="step">
							<!-- 发起审批 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">1
										<view class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view>
									<view class="line"></view>
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.user_name}}</view>
											<view class="tips">发起项目审批</view>
										</view>
										<view class="date">{{detail.create_time}}</view>
									</view>
								</view>
							</view>
							
							<!-- 审批人确认 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">2
										<view v-if="detail.is_agree==2" class="success-icon iconfont f-red f-s30">&#xe724;</view>
										<view v-if="detail.is_agree==1" class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view>
									<view class="line"></view>
								</view>
								<view class="right"> 
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.approver_name}}</view>
											<view class="tips">
												<text v-if="detail.is_agree==0">待审批</text>
												<text v-if="detail.is_agree==1">审批通过</text>
												<text v-if="detail.is_agree==2">审批不通过</text>
											</view>
										</view>
										<view class="date"></view>
									</view> 
									
									<template v-if="detail.is_agree==0">			
										<c-loading v-if="project_loading.default" :loadingState="project_loading"></c-loading>
										<template v-else>
											<view v-if="detail.is_agree<2&&sp.project.status<2" class="sp-form">									
												<textarea v-model="comment" placeholder="审批意见"></textarea>
												<view class="btn-wrap">
													<view class="btn back" @click="agreeProject(2)">驳回</view>
													<view class="btn pass" @click="agreeProject(1)">同意</view>
												</view>
											</view>	
										</template>
									</template>
								</view>
							</view>
							
							<!-- 指派项目经理 -->
							<view v-if="sp.project.status>=2&&sp.project.status!=7"  class="item">
								<view class="left">
									<view class="step-num active">3
										<view v-if="sp.project.responsible_name" class="success-icon iconfont f-green f-s30">&#xe637;</view>	
									</view>
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.responsible_name?sp.project.responsible_name:'项目经理'}}</view>
											<view class="tips">{{sp.project.responsible_name?'已指派项目经理':'待指派'}}</view>
										</view>
										<view class="date"></view>
									</view>
									<view v-if="!sp.project.responsible_name" class="flow-wrap">
										<view class="mail-user">
											<view class="user-item" v-if="sp.project_manage.username">
												<view class="avator">
													{{sp.project_manage.username|substringUsername(sp.project_manage.username)}} 
													<view class="del-btn iconfont" @click="deluser">&#xe724;</view>
												</view> 
											</view>
											<navigator v-else url="/package_msg/mailUser/mailUser?scene=2&type=1" hover-class="none" class="add-user-btn">
												<image src="@/static/images/add.png" mode="widthFix"></image>
											</navigator>									
										</view> 
										<view class="btn-wrap">
											<view class="btn pass" @click="setManage(1)">确定指派</view>
										</view>
									</view>
								</view>
							</view> 
							
							<!-- 负责人 -->
							<view v-if="sp.project.status>=2&&sp.project.responsible_name&&sp.project.status!=7" class="item">
								<view class="left">
									<view class="step-num active">4
										<view v-if="sp.project.director_name" class="success-icon iconfont f-green f-s30">&#xe637;</view>							
									</view> 
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.director_name?sp.project.director_name:'项目负责人'}}</view>
											<view class="tips">{{sp.project.director_name?'指派为项目负责人':'待指派'}}</view>
										</view>
										<view class="date"></view>
									</view>
									<view v-if="!sp.project.director_name&&sp.project.responsible==userInfo.id" class="flow-wrap">
										<view class="mail-user">
											<view class="user-item" v-if="sp.project_manage.username">
												<view class="avator">
													{{sp.project_manage.username|substringUsername(sp.project_manage.username)}} 
													<view class="del-btn iconfont" @click="deluser">&#xe724;</view>
												</view> 
											</view>
											<navigator v-else url="/package_msg/mailUser/mailUser?scene=2&type=1" hover-class="none" class="add-user-btn">
												<image src="@/static/images/add.png" mode="widthFix"></image>
											</navigator>									
										</view> 
										<view class="btn-wrap">
											<view class="btn pass" @click="setManage(2)">确定指派</view>
										</view>
									</view>
								</view>
							</view> 
						</view>
					</view>
				</template>

				<!-- 任务指派 -->
				<template v-if="type==3">
					<view class="sp-step-area m-b2">
						<view class="hd">审批过程</view>
						<view class="step">
							<!-- 发起人 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">1
										<view class="success-icon iconfont f-green f-s30">&#xe637;</view> 
									</view>
									<view class="line"></view>
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.user_name}}</view>
											<view class="tips">发起审批</view>
										</view>
										<view class="date">{{detail.create_time}}</view>
									</view>
								</view>
							</view>
							
							<!-- 审批人审批 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">2
										<view v-if="sp.project.status>=2&&sp.project.status!=7" class="success-icon iconfont f-green f-s30">&#xe637;</view> 	 
									</view>
									<view class="line"></view>
								</view>
								<view class="right"> 
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.approver_name}}</view>
											<view class="tips">{{sp.project.status>=2?'审批通过':'待审批'}}</view>
										</view>
										<view class="date"></view>
									</view> 
									
									<c-loading v-if="project_loading.default" :loadingState="project_loading"></c-loading>
									<template v-else>
										<view v-if="sp.project.status<2" class="sp-form">									
											<textarea name="" placeholder="审核意见"></textarea>
											<view class="btn-wrap">
												<view class="btn back">驳回</view>
												<view class="btn pass" @click="agree">同意</view>
											</view>
										</view>	
									</template>
								</view>
							</view>
							
							<!-- 项目经理 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">3 
										<view v-if="sp.project.responsible_name" class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view> 
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.responsible_name?sp.project.responsible_name:'项目经理'}}</view>
											<view class="tips">{{sp.project.responsible_name?'指派为项目经理':'待指派'}}</view>
										</view>
										<view class="date"></view>
									</view>
									<view v-if="!sp.project.responsible_name" class="flow-wrap">
										<view class="mail-user">
											<view class="user-item" v-if="sp.project_manage.username">
												<view class="avator">
													{{sp.project_manage.username|substringUsername(sp.project_manage.username)}} 
													<view class="del-btn iconfont" @click="deluser">&#xe724;</view>
												</view> 
											</view>
											<navigator v-else url="/package_msg/mailUser/mailUser?scene=2&type=1" hover-class="none" class="add-user-btn">
												<image src="@/static/images/add.png" mode="widthFix"></image>
											</navigator>									
										</view> 
										<view class="btn-wrap">
											<view class="btn pass" @click="setManage(1)">确定指派</view>
										</view>
									</view>
								</view>
							</view>
							
							<!-- 负责人 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">4
										<view v-if="sp.project.director_name" class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view> 
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.director_name?sp.project.director_name:'项目负责人'}}</view>
											<view class="tips">{{sp.project.director_name?'指派为项目负责人':'待指派'}}</view>
										</view>
										<view class="date"></view>
									</view>
									<view v-if="!sp.project.director_name&&sp.project.responsible==userInfo.id" class="flow-wrap">
										<view class="mail-user">
											<view class="user-item" v-if="sp.project_manage.username">
												<view class="avator">
													{{sp.project_manage.username|substringUsername(sp.project_manage.username)}} 
													<view class="del-btn iconfont" @click="deluser">&#xe724;</view>
												</view> 
											</view>
											<navigator v-else :url="'/package_msg/mailUser/mailUser?scene=2&type=1'+'&department_id='+sp.project.responsible_depid" hover-class="none" class="add-user-btn">
												<image src="@/static/images/add.png" mode="widthFix"></image>
											</navigator>									
										</view> 
										<view class="btn-wrap">
											<view class="btn pass" @click="setManage(2)">确定指派</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</template>				 
				
				<!-- 申请延期 -->
				<template v-if="type==5"> 
					<view class="sp-step-area m-b2">
						<view class="hd">审批过程</view>
						<view class="step">
							<!-- 发起审批 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">1
										<view class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view>
									<view class="line"></view>
								</view>
								<view class="right">
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.responsible_name}}</view>
											<view class="tips">发起项目延期申请</view>
										</view>
										<view class="date">{{detail.create_time}}</view>
									</view>
								</view>
							</view>
							
							<!-- 审批人确认 -->
							<view class="item">
								<view class="left">
									<view class="step-num active">2
										<view v-if="sp.project.has_delay==0" class="success-icon iconfont f-green f-s30">&#xe637;</view>
									</view>
									<view class="line"></view>
								</view>
								<view class="right"> 
									<view class="title-bar">
										<view class="">
											<view class="name">{{sp.project.approver_name}}</view>
											<view class="tips">
												<text v-if="detail.is_agree==0">待审批</text>
												<text v-if="detail.is_agree==1">审批通过</text>
												<text v-if="detail.is_agree==2">审批不通过</text>
											</view>
										</view>
										<view class="date"></view>
									</view> 
									
									<c-loading v-if="project_loading.default" :loadingState="project_loading"></c-loading>
									<template v-else>
										<view class="sp-form">		
											<view class="date m-b1">合同日期：{{sp.project.format_end_time}}</view>
											<view class="date m-b2">延期日期：{{detail.delay_time}}</view>
											<template v-if="sp.project.has_delay>0">
												<textarea v-model="comment" placeholder="审批意见"></textarea>
												<view class="btn-wrap">
													<view class="btn back" @click="aplayDate(2)">驳回</view>
													<view class="btn pass" @click="aplayDate(1)">同意</view>
												</view>
											</template>
										</view>	
									</template>
								</view>
							</view> 
							 
						</view>
					</view>
				</template>
			</template>
			
			<c-empty v-else msg="该项目不存在"></c-empty>
		</template>
		
		 	
		  
	</view> 
</view>
</template>

<script>
 

export default{
	name:'list',
	data(){
		return {
			isLogin:true,
			id:'', 
			pro_id:'',
			is_read:'',
			type:'',
			comment:'',
			sp:{
				project:null,
				project_manage:{},   // 项目经理
				director_manage:{}   // 负责人
			},
			detail:{}, 
			htmlContent:[], 
			loadingState:{
				default:true
			}, 
			project_loading:{
				default:true
			},
			loading:0,
			userInfo:uni.getStorageSync('userInfo'),
			isStop:true
		}
	},
	async onLoad(params) {    
		console.log(params)
		this.isLogin = await this.$loginState('check'); 
		this.id=params.id; 		 
		this.type=params.type;
		this.is_read=params.is_read;		
		if(params.pro_id){
			this.pro_id=params.pro_id;
		}
		if(this.type==0){			
			uni.setNavigationBarTitle({
				title:'审批详情'
			})
		}
		if(this.type==1){
			uni.setNavigationBarTitle({
				title:'督办详情'
			})
		} 
		if(this.type==2){
			uni.setNavigationBarTitle({
				title:'回款通知'
			})
		} 
		if(this.type==3){
			uni.setNavigationBarTitle({
				title:'任务指派'
			})
		} 
		if(this.type==4){
			uni.setNavigationBarTitle({
				title:'通知消息'
			})
		}
		if(this.type==5){
			uni.setNavigationBarTitle({
				title:'延期申请'
			})
		}
		
		if(this.isLogin){ 
			
			this.sp.project= await this.getProjectDetail();
			if(this.sp.project){
				this.getMsgInfo();					
			}else{
				this.loadingState.default=false;
				this.msgRead();
			}
			
			if(this.type!=0&&this.type!=5){
				this.getMsgInfo();
				this.msgRead();
			}
			// this.msgRead();
		}
		
	},
	filters: {
		substringUsername(val) {
			if (val) return val.substring(val.length - 2);
		},
	},
	mounted() {
		 
	},
	onReachBottom(){
		 
	},
	methods:{
		// 消息已读
		async msgRead(){
			let res=await this.$api.user_api.msgRead({
				id:this.id
			}) 
			console.log(res)
			if(res.data.code==200){ 
				this.$store.commit('MSG_LIST_UPDATE',1)
			}
		},
		
		
		// 获取消息
		async getMsgInfo(){
			let res=await this.$api.user_api.getMsgInfo({
				id:this.id
			})     
			console.log(res)
			if(res.data.code==200){
				this.loadingState.default=false;
				this.detail=res.data.data;
			}
		},
		
		// 项目详情
		async getProjectDetail() {
			let res = await this.$api.user_api.projectInfo({
				id: this.pro_id
			})  
			console.log(res)
			if (res.data.code == 200) {
				this.project_loading.default=false;
				return res.data.data; 
			} 
		},
		
		// 删除选中人
		deluser(){
			this.sp.project_manage={};  
		},
		
		// 审核通过项目
		async agreeProject(type){
			// type 1 同意  2 不同意
			let content="",
				title='';
			
			if(type==1){
				if(this.comment==''){
					this.comment='同意';
				}
				title='《'+this.sp.project.project_name+'》项目审批通过通知';
				content='您创建的《'+this.sp.project.project_name+'》项目，已由【'+this.sp.project.approver_name+'】审批通过，请知悉！';
			}
			if(type==2){
				if(this.comment==''){
					this.$showToast({
						title:'请输入驳回原因',
					})
					return
				}
				title='《'+this.sp.project.project_name+'》项目被驳回通知';
				content='您创建的《'+this.sp.project.project_name+'》项目，已由【'+this.sp.project.approver_name+'】驳回，请根据驳回原因更新后重新提交审批！';
			} 
			
			if(this.isStop){
				this.isStop=false;
				let a_res=await this.$api.user_api.agreeApprover({
					id:this.id,
					comment:this.comment,
					is_agree:type
				})  
				if(a_res.data.code==200){
					this.isStop=true;
					if(type==1){
						// 同意审批
						let update_status = await this.$api.project_api.updateProjectStatus({
							id: this.pro_id,
							status: '2',
							content: this.sp.project.approver_name+'审批完成',
						}) 
						this.sp.project.status=2;
						this.detail.is_agree=1;
						this.$store.commit('PROJECT_LIST_UPDATE',1);
						this.$showToast({
							icon:'success',
							title:'审批完成',
							duration:1000,
						}) 
						
						// 发送消息给创建人
						let res=await this.$api.user_api.addMsg({
							project_id:this.pro_id, 
							task_id:'',
							content:content,
							user_id:this.sp.project.user_id,
							type:1,
							content_type:4,
							comment:this.comment,
							title:title
						}); 
						
						
						
					}else{
						// 不同意审批
						let update_status = await this.$api.project_api.updateProjectStatus({
							id: this.pro_id,
							status: '7',
							content: this.comment,
						})
						this.sp.project.status=7;
						this.detail.is_agree=2;
						this.$store.commit('PROJECT_LIST_UPDATE',1);
						this.$showToast({
							icon:'success',
							title:'审批完成',
							duration:1000,
						}) 
						
						// 发送消息给创建人
						let res=await this.$api.user_api.addMsg({
							project_id:this.pro_id, 
							task_id:'',
							content:content,
							user_id:this.sp.project.user_id,
							type:1,
							content_type:4,
							title:title
						});  
						this.msgRead();
					}
				}else{
					this.$showToast({
						title:a_res.data.msg,
					})
					this.isStop=true;
				}
			}
			
		},
		
		// 审核延期申请
		async aplayDate(type){
			// type 1 同意  2 不同意
			let content="",
				title='';
			
			if(type==1){
				if(this.comment==''){
					this.comment='同意';
				}
				title='《'+this.sp.project.project_name+'》项目申请延期通过通知';
				content='您提交的《'+this.sp.project.project_name+'》项目延期申请，已由【'+this.sp.project.approver_name+'】审批通过，请知悉！';
			}
			if(type==2){
				if(this.comment==''){
					this.$showToast({
						title:'请输入驳回原因',
					})
					return
				}
				title='《'+this.sp.project.project_name+'》项目申请延期驳回通知';
				content='您提交的《'+this.sp.project.project_name+'》项目延期申请，已由【'+this.sp.project.approver_name+'】驳回，请知悉！';
			} 
			
			if(this.isStop){
				this.isStop=false; 
				let update_status = await this.$api.user_api.agreeDelay({
					id: this.id,
					is_agree: type, 
				})  
				if(update_status.data.code==200){ 
					if(type==1){
						this.$showToast({
							icon:'success',
							title:'审批成功',
							duration:1000,
						}).then(async ()=>{	 
							this.sp.project.has_delay=0; 
							this.detail.is_agree=1;
							this.$store.commit('PROJECT_LIST_UPDATE',1); 
						})		
					}else{
						this.$showToast({
							icon:'success',
							title:'驳回成功',
							duration:1000,
						}) 
						this.detail.is_agree=2;
					}
					
					let res=await this.$api.user_api.addMsg({
						project_id:this.pro_id, 
						task_id:'',
						content:content,
						user_id:this.sp.project.responsible,
						type:1,
						content_type:4,
						comment:this.comment,
						title:title
					});  
					setTimeout(()=>{
						this.isStop=true;
						this.msgRead(); 	
						uni.navigateBack({
							delta:1
						})
					},1000)
					
					    
				}else{
					this.isStop=true;
					this.$showToast({
						icon:'error',
						title:res.data.msg,
						duration:1000,
					})
				}
			}
			
		},
		async agree(){
			let content="",
				title='';
			// 审批消息
			if(this.type==0){
				title='《'+this.sp.project.project_name+'》项目审批通过通知';
				content='您创建的《'+this.sp.project.project_name+'》项目，已由【'+this.sp.project.approver_name+'】审批通过，请知悉！';
			}
			// 延期申请
			if(this.type==5){
				title='《'+this.sp.project.project_name+'》项目申请延期通过通知';
				content='您提交的《'+this.sp.project.project_name+'》项目延期申请，已由【'+this.sp.project.approver_name+'】审批通过，请知悉！';
			}
			if(this.isStop){
				this.isStop=false; 
				// 审批
				if(this.type==0){
					let update_status = await this.$api.project_api.updateProjectStatus({
						id: this.pro_id,
						status: '2',
						content: this.sp.project.approver_name+'审批完成',
					})
					if(update_status.data.code==200){ 	
						this.sp.project.status=2;
						this.$store.commit('PROJECT_LIST_UPDATE',1);
						this.$showToast({
							icon:'success',
							title:'审批成功',
							duration:1000,
						}) 
						
						// 发送消息给创建人
						let res=await this.$api.user_api.addMsg({
							project_id:this.pro_id, 
							task_id:'',
							content:content,
							user_id:this.sp.project.user_id,
							type:1,
							content_type:4,
							title:title
						});  
						this.isStop=true;
						 
					}else{
						this.isStop=true;
						this.$showToast({
							icon:'error',
							title:res.data.msg,
							duration:1000,
						})
					}
					
					
					
					  
				}
				
				// 延期申请
				if(this.type==5){
					let update_status = await this.$api.user_api.agreeDelay({
						id: this.id,
						is_agree: 1, 
					}) 
					if(update_status.data.code==200){ 
						let res=await this.$api.user_api.addMsg({
							project_id:this.pro_id, 
							task_id:'',
							content:content,
							user_id:this.sp.project.responsible,
							type:1,
							content_type:4,
							title:title
						});    
						if(res.data.code==200){ 
							this.$showToast({ 
								icon:'success',
								title:'审批成功',
								duration:1000,
							}).then(async ()=>{	
								this.isStop=true; 
								this.sp.project.has_delay=0;
								this.msgRead();
								this.$store.commit('PROJECT_LIST_UPDATE',1);
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},1000)
							})							
						}else{
							this.isStop=true;
							this.$showToast({
								icon:'error',
								title:res.data.msg,
								duration:1000,
							})
						}  
					}
				}
				
			}			   
		},
		
		// 指派项目经理
		async setManage(type){
			if(!this.sp.project_manage.id){
				this.$showToast({
					title:'请先选择指派人',
				})
				return
			}
			
			if(this.isStop){
				this.isStop=false;
				if(!this.sp.project_manage.id){
					this.$showToast({ 
						title:'请选择审核人',
						duration:1000,
					})
					return
				} 
				
				// 指派项目经理
				if(type==1){
					let res=await this.$api.user_api.addMsg({
						project_id:this.pro_id, 
						task_id:'',
						content:'【'+this.sp.project.approver_name+'】指派【'+this.sp.project_manage.username+'】为《'+this.sp.project.project_name+'》项目经理，请尽快成立项目小组开展实施项目！',
						user_id:this.sp.project_manage.id,
						type:1,
						content_type:3,
						title:'指派您为《'+this.sp.project.project_name+'》的项目经理的通知'
					});    
					if(res.data.code==200){
						this.$showToast({  
							title:'指派成功',
							duration:1000,
						}).then(async ()=>{
							this.msgRead();	
							this.$store.commit('PROJECT_LIST_UPDATE',1);	
							
							// 发送标书组
							let sp_res=await this.$api.user_api.addMsg({
								project_id:this.pro_id, 
								task_id:'',
								content:this.sp.project.user_name+'创建的《'+this.sp.project.project_name+'》项目已通过审批，【'+this.sp.project.approver_name+'】指派您尽快完成标书相关文件上传！',
								user_id:'27',
								type:1,
								content_type:3,
								title:'关于《'+this.sp.project.project_name+'》项目上传标书的消息'
							});  
							
							// 发送消息给综合部负责人 指派报告撰写人
							let c_res=await this.$api.user_api.addMsg({
								project_id:this.pro_id, 
								task_id:'',
								content:'《'+this.sp.project.project_name+'》项目，已由【'+this.sp.project.approver_name+'】审批通过，请指派项目撰写人负责跟进项目！',
								user_id:21,
								type:1,
								content_type:4,
								comment:'',
								title:'《'+this.sp.project.project_name+'》指派项目报告撰写人通知'
							}); 
							
							
							// 更新项目状态
							let update_status = await this.$api.project_api.updateProjectStatus({
								id: this.pro_id,
								status: '3',
								content: '指派给'+this.sp.project_manage.username+'跟进',
							})
							if(update_status.data.code==200){
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},1000)
							}
							
							// 更新项目项目经理
							let set_res=await this.$api.user_api.addResponsible({
								project_id:this.pro_id,
								user_id:this.sp.project_manage.id
							}) 
							if(set_res.data.code==200){
								this.sp.project.responsible_name=this.sp.project_manage.username;
							}
							// 更新项目状态
							
							
						})
						this.isStop=true;
					}else{
						this.isStop=true;
						this.$showToast({
							icon:'error',
							title:res.data.msg,
							duration:1000,
						})
					} 
					 
				}
				
				// 指派项目负责
				if(type==2){
					let res=await this.$api.user_api.addMsg({
						project_id:this.pro_id, 
						task_id:'',
						content:'【'+this.sp.project.responsible_name+'】指派【'+this.sp.project_manage.username+'】为《'+this.sp.project.project_name+'》项目负责人，请尽快开展实施项目！',
						user_id:this.sp.project_manage.id,
						type:1,
						content_type:3,
						title:'指派您为《'+this.sp.project.project_name+'》的项目负责人的通知'
					});  
					if(res.data.code==200){
						this.$showToast({  
							title:'指派成功',
							duration:1000,
						}).then(async ()=>{
							this.msgRead();	
							this.$store.commit('PROJECT_LIST_UPDATE',1);	
							
							
							// 更新项目负责人
							let set_res=await this.$api.user_api.addDirector({
								project_id:this.pro_id,
								user_id:this.sp.project_manage.id
							})  
							if(set_res.data.code==200){
								this.sp.project.director_name=this.sp.project_manage.username;
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},1000)
							}
							 
							// 更新项目状态
							
							
						})
						this.isStop=true;
					}else{
						this.isStop=true;
						this.$showToast({
							icon:'error',
							title:res.data.msg,
							duration:1000,
						})
					} 
					 
				}
				 
				
			}
		} 
		 
	},
	components:{   
	},
	computed:{
		project_manage_state(){
			return this.$store.state.project_manage_state;
		} 
	},
	watch:{
		project_manage_state(newer,older){
			this.sp.project_manage=newer; 
		} 
	}
}
</script>

<style lang="less" scoped> 
.body{
	overflow: auto;
	// background: #fff;
}

.msg-title{
	margin: 30rpx;
	font-size: 30rpx;
	font-weight: bold;
	text-align: center;
}

.content{
	padding:30rpx;
	text-indent: 2em;
	font-size: 28rpx;
}

.porject-bar{
	display: flex;
	justify-content: space-between;
	font-size: 30rpx;
	.title{
		flex-grow: 2;
		max-width: 90%;
	}
	text{
		flex-shrink: 0;
		color:#09f;
	}
}

.sp-step-area{
	margin: 0 30rpx;
	padding:20rpx 30rpx;
	background: #fff;
	border-radius: 10rpx;
	.hd{
		margin-bottom: 30rpx;
		font-size: 30rpx;
		font-weight: bold;
	}
	.step{
		.item{
			display: flex;	
			align-items: flex-start;
			margin:0 0 10rpx 20rpx;
			border-left: 1rpx solid #eee;
			min-height: 150rpx;
			&:last-child{
				border-left: 0 none;
			}
			.left{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				margin-right: 20rpx;
				.step-num{
					position: relative;
					left:-20rpx;
					flex-shrink: 0;
					width: 40rpx;
					height: 40rpx;
					margin: 0 0 10rpx;
					line-height: 40rpx;
					background: #f5f5f5;
					box-shadow: 0 0 5rpx #ccc;
					border-radius: 50%;
					color:#999;
					font-size: 28rpx;
					text-align: center;
					.success-icon{
						position: absolute;
						right:-15rpx;
						bottom:-15rpx;
						width: 24rpx; 
					}
				}
				.active{
					background: #09f;
					color:#fff;
				} 
			}
			.right{
				flex-grow: 2;
				max-width: 90%;
				.title-bar{
					display: flex;
					justify-content: space-between;
					margin-bottom: 20rpx;
					.name{
						font-size: 28rpx;
						font-weight: bold;
					}
					.date{
						font-size: 28rpx;
						color:#999;
					}
					.tips{
						font-size: 28rpx;
						color:#999;
					}
				}
				
			}
			
		}
		.sp-form{
			margin-bottom: 40rpx;
			.date{
				font-size: 28rpx;
				color:#999;
			}
			textarea{
				width: 90%;
				height:150rpx;
				padding:20rpx 5%;
				margin-bottom: 20rpx;
				background: #f5f5f5;
				border-radius: 15rpx;
				font-size: 28rpx;
			}
			.btn-wrap{ 
				display: flex;
				justify-content: space-between;
				.btn{ 
					width: 44%;
					height: 60rpx;
					line-height: 60rpx;
					border-radius: 38rpx;
					font-size: 28rpx;
					text-align: center;
				}
				.pass{
					border:1rpx solid #09f;
					background: #09f;
					color:#fff;
				}
				.back{
					border:1rpx solid #ddd;
					color:#666;
				}
			}
		}
	}
}

.flow-wrap{
	.mail-user{
		display: flex;
		justify-content: flex-end;
		margin-bottom: 30rpx;
		.add-user-btn{
			width:70rpx; 
			image{
				width: 100%;
			}
		}
	}
	.btn-wrap{
		display: flex;
		justify-content: flex-end;
		.btn{ 
			width: 44%;
			height: 60rpx;
			line-height: 60rpx;
			border-radius: 38rpx;
			font-size: 28rpx;
			text-align: center;
		}
		.pass{
			border:1rpx solid #09f;
			background: #09f;
			color:#fff;
		} 
	}
}


.content-area{
	background: #fff;
	padding:20rpx;
	margin-bottom: 20rpx;
	.title{
		margin-bottom:30rpx;
		font-size:30rpx;
		font-weight: bold;
		text-align: center;
	}
	.project-info{
		font-size: 28rpx;
		navigator{
			color:#09f;
		}
	}
	.label-bar{
		margin-bottom: 40rpx;;
		font-size:26rpx;
		color:#999;
		text{
			margin-right: 20rpx;
		}
	} 
	.content{
		margin-bottom:40rpx;
		overflow: hidden;
		font-size: 28rpx;
	}
	 
}
.content { 
	::v-deep .html_p{
		line-height: 54rpx;
		text-align: left!important;
		margin-bottom: 20rpx;
		text-indent: 2em;
		font-size: 32rpx; 
	}
	::v-deep .html_img{
		width: 100%!important;
		height: auto!important;
		margin:20rpx 0 20rpx -2em;
		
	}
	
}
.msg-tips{
	padding:30rpx;
	text-align: right;
	font-size: 30rpx;
	color: #666;	
}
 
</style>